package org.example.todo.model;

import lombok.Getter;
import lombok.Setter;

import static org.example.todo.constants.ResponseCode.*;

@Getter
@Setter
public class Result<T> {
    private int code;
    private String msg;
    private T data;

    private Result(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Result<?> ok() {
        return new Result<>(OK, OK_MSG, null);
    }

    public static Result<?> fail(String errorMessage) {
        return new Result<>(FAIL, FAIL_MSG, errorMessage);
    }

    public static <T> Result<T> ok(T data) {
        return new Result<>(OK, OK_MSG, data);
    }
}
